home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 09 - 1993 / 09.04 Apr 93 / Creating EPSF Files / PSDtext.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-07-16  |  1.3 KB  |  45 lines  |  [TEXT/KAHL]

  1. /* PSDtext.c */
  2. /* This module contains the routines for bitmap operations */
  3. /* Copyright 1992, Gary D. McGath */
  4.  
  5. #include "psd.h"
  6.  
  7. pascal psdTextProc(short byteCount, Ptr textBuf, Point numer, Point denom);
  8. void SelectFont(void);
  9.  
  10. extern int thePSFile;            /* ID of file to output to */
  11. extern int gblFont;
  12. extern int gblSize;
  13.  
  14. pascal psdTextProc(short byteCount, Ptr textBuf, Point numer, Point denom) 
  15. {
  16.     register int i;
  17.     SelectFont();                /* determine font and issue font commands */
  18.     OutputString("/SV save def ",thePSFile);
  19.     OutputNum(thePort->pnLoc.h,thePSFile);
  20.     OutputNum(thePort->pnLoc.v,thePSFile);
  21.     OutputString("translate 1 -1 scale ",thePSFile);
  22.     OutputString("0 0 moveto\r",thePSFile);
  23.     
  24.     /* The following code will fail in various cases, most notably unbalanced
  25.        parentheses within the string. */
  26.     OutputChar('(', thePSFile);
  27.     for (i = 0; i < byteCount; i++)
  28.         OutputChar(textBuf[i],thePSFile);
  29.     OutputString(") show SV restore\r", thePSFile);
  30. }
  31.  
  32.  
  33. void SelectFont()
  34. {
  35.     if (thePort->txFont != gblFont || thePort->txSize != gblSize) {
  36.         
  37.         /* "Real" code needs to look up the PostScript font name */
  38.         OutputString("/Times-Roman findfont ",thePSFile);
  39.         OutputNum(thePort->txSize, thePSFile);
  40.         OutputString("scalefont setfont\r",thePSFile);
  41.         gblFont = thePort->txFont;
  42.         gblSize = thePort->txSize;
  43.     }
  44. }
  45.